from torch.utils.data import Dataset
import os
from PIL import Image


class MyLoader(Dataset):
    def __init__(self, root_dir, label_dir):
        self.root_dir: str = root_dir
        self.label_dir: str = label_dir
        self.path: str = os.path.join(self.root_dir, self.label_dir)
        self.img_path = os.listdir(path=self.path)

    def __getitem__(self, idx):
        img_name = self.img_path[idx]
        img_item_path = os.path.join(self.root_dir, self.label_dir, img_name)
        img = Image.open(img_item_path)
        label = self.label_dir
        return img, self.label_dir

    def __len__(self):
        return len(self.img_path)


